<template>
  <div class="login">
  </div>
</template>

<script setup>
import useUserStore from '@/store/modules/user'

const userStore = useUserStore()
const route = useRoute();
const router = useRouter();

const loading = ref(false);
const redirect = ref(undefined);
const loginForm = ref({
  username: "",//admin
  password: "",//admin123
  rememberMe: false,
  code: "",
  uuid: ""
});

onMounted(() => {
  loginSso()
})

function loginSso() {
  loading.value = true;
  // 调用action的登录方法
  const query = route.query;
  loginForm.value.username = query.username;
  loginForm.value.password = query.password || "admin123";
  const projectCode = query.projectCode || "";
  //console.log('projectCode='+projectCode)
  userStore.login(loginForm.value).then(() => {
    router.push({ path: "/craneSingle/"+projectCode});
  }).catch(() => {
    loading.value = false;
  });
}

</script>
